//
//  WuLiRequestCommitAPI.m
//  WULIHH
//
//  Created by tang on 16/4/18.
//  Copyright © 2016年 tang. All rights reserved.
//

#import "WuLiRequestCommitAPI.h"
#import "Header.h"
#import "UserInfoModel.h"

#import "AFNetworking.h"

@implementation WuLiRequestCommitAPI



+ (id)requestWorkCommit:(NSString *)workID
{
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    
    [manager.requestSerializer setValue:[UserInfoModel tokenString] forHTTPHeaderField:@"X-AUTH-TOKEN"];
    [manager.requestSerializer setValue:appVersion forHTTPHeaderField:@"X-APP-VERSON"];
    [manager.requestSerializer setValue:typetext forHTTPHeaderField:@"Content-Type"];
    
    NSString *httpString = [NSString stringWithFormat:@"%@%@%@/%@/",hostName, zuopinpinglunAPI, workID, @"comment"];
    
    
        NSLog(@"%@", httpString);
    [manager GET:httpString parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
        // 这里可以获取到目前的数据请求的进度
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        // 请求成功，解析数据
        //        NSLog(@"%@", responseObject);
        NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers | NSJSONReadingMutableLeaves error:nil];
        [[NSNotificationCenter defaultCenter] postNotificationName:zuopinpinglin object:nil userInfo:dic];
//                NSLog(@"%@", dic);
        
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        // 请求失败
        NSLog(@"%@", [error localizedDescription]);
    }];

    return self;
}



@end
